<?php namespace Common\Model;

use Hdphp\Model\Model;

class Adminuser extends Model{

    protected $table = "adminuser";
	//自动验证
	protected $validate = array(
        array('password1','minlen:6','密码不得小于6位',3,3),
        array('password','confirm:password1','两次密码输入不一致',3,3),
    ); 
	public function store(){
		//判断自动登录
	    if(!$this->create()) return false;
		//判断旧密码是否正确
		$password=Q('post.oldPwd');
		$data=$this->where("password='{$password}'")->find();
		if(!$data){
			$this->error='原密码输入错误！';
			return false;
		}
		$this->data['id']=$_SESSION['uid'];
		//执行添加
		$this->add();
		return true;
	}
	
	
	
}